#!/bin/bash
declare -a Teksti #teksti luetaan matriisiin joka sitten tulostetaan
exec 10<&0 # Määrää järjestelmä lukemaan "tiedostokuvaaja 10:stä" näppäimistön sijasta
exec < /boot/grub/grub.cfg  # määrää "tiedostokuvaaja 10:ksi" tiedosto /boot/grub/grub.cfg
rivinumero=0
while read rivi; do # tyhjäkin rivi on jotakin mutta tiedostonlopun jälkeen rivi:in ei tule mitään
    Teksti[$rivinumero]=$rivi
    (( rivinumero++ ))
done
echo -e ' '"${Teksti[@]/%/\\n}"
exec 0<&10 10<&- # palauta lukeminen tapahtuvaksi näppäimistöltä
read -p 'lopettaakseesi paina enter' apu

# toinen konsti
for apu in `ls -R ~/omatskriptit`
do
  test `echo $apu | grep "\/"` && polku=${apu:0:${#apu-1}}
echo $polku
  if [ -f $polku/$apu ]; then
    echo $polku/$apu
read apu
  fi
done
exit


read apu
    while read myline
    do
      test "$(echo $myline | grep SiniVihreä)" && echo /omatskriptit/"$apu"
    done < /omatskriptit/"$apu" 
read -p 'Jatkaakseesi paina enter' apu
exit



# or only to screen:
exec 10<&0 # Order system to read from filedescriptor number 10
exec < /boot/grub/grub.cfg # Order filedescriptor number 10 to be ~/file.txt 
while read rivi; do echo $rivi; done
exec 0<&10 10<&- # return things as they were
read -p 'press enter to exit' apu


